package com.xxzb.pack0824.线程池;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 带有缓冲区的线程池
 */
public class CachedThreadPoolDemo {
    public static void main(String[] args) {
        //创建带有缓冲区的线程池
        ExecutorService executorService = Executors.newCachedThreadPool();
        //获取线程池对象，根据提交的线程任务创建线程，没有上限(21亿个吧)
        ThreadPoolTask task = new ThreadPoolTask();
        //给了10个任务全用上了
        for (int i = 0; i < 10; i++) {
            executorService.submit(task);

        }
        executorService.shutdown();
    }
}
